---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: profile-server
  labels:
    db: pgsql
spec:
  selector:
    matchLabels:
      name: profile-server
  template:
    metadata:
      labels:
        name: profile-server
    spec:
      containers:
      - name: profile-server
        imagePullPolicy: IfNotPresent
        image: cloud-profile_server_image
        ports:
        - containerPort: 51500
          name: http2
        - containerPort: 51501
          name: metrics-http
        readinessProbe:
          httpGet:
            scheme: HTTPS
            path: /healthz
            port: 51500
        livenessProbe:
          httpGet:
            scheme: HTTPS
            path: /healthz
            port: 51500
        envFrom:
        - configMapRef:
            name: pl-db-config
        - configMapRef:
            name: pl-tls-config
        - configMapRef:
            name: pl-domain-config
        - configMapRef:
            name: pl-ory-service-config
        - configMapRef:
            name: pl-errors-config
            optional: true
        env:
        - name: PL_JWT_SIGNING_KEY
          valueFrom:
            secretKeyRef:
              name: cloud-auth-secrets
              key: jwt-signing-key
        - name: PL_DATABASE_KEY
          valueFrom:
            secretKeyRef:
              name: pl-db-secrets
              key: database-key
        - name: PL_POSTGRES_USERNAME
          valueFrom:
            secretKeyRef:
              name: pl-db-secrets
              key: PL_POSTGRES_USERNAME
        - name: PL_POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: pl-db-secrets
              key: PL_POSTGRES_PASSWORD
        - name: PL_PROJECT_MANAGER_SERVICE
          valueFrom:
            configMapKeyRef:
              name: pl-service-config
              key: PL_PROJECT_MANAGER_SERVICE
        volumeMounts:
        - name: certs
          mountPath: /certs
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - ALL
          runAsNonRoot: true
          runAsUser: 10100
          seccompProfile:
            type: RuntimeDefault
      securityContext:
        runAsNonRoot: true
        runAsUser: 10100
        seccompProfile:
          type: RuntimeDefault
      volumes:
      - name: certs
        secret:
          secretName: service-tls-certs
